package 华为练习2;

import java.util.*;

/**
 * Created by hest0 on 2017/7/14.
 */
public class 通配符问题 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            String s1 = sc.next();
            String s2 = sc.next();

            System.out.println(match(s1, s2));
        }
    }

    private static boolean match(String s1, String s2) {
        int i = 0;
        int j = 0;

        while (i < s1.length() && j < s2.length()) {
            if (s1.charAt(i) == s2.charAt(j)) {
                i++;
                j++;
            } else if (s1.charAt(i) == '?') {
                i++;
                j++;
            } else if (s1.charAt(i) == '*') {
                if (s1.length() == s2.length()) {
                    i++;
                    j++;
                } else
                    j++;
            } else
                return false;
        }

        return j >= s2.length();
    }
}